﻿using MediatR;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;
using S.EarTag.Read.API.Mediator.MediatorCommand.EarTagCommand;

namespace S.EarTag.Read.API.Mediator.MediatorCommandHandler.EarTagCommandHandler
{
    public class EarTagQueryCommandHandler : IRequestHandler<EarTagQueryCommand, List<EarTagModel>>
    {
        private readonly IEarTagModelRepository _earTagModelRepository;
        public EarTagQueryCommandHandler(IEarTagModelRepository earTagModelRepository)
        {
            _earTagModelRepository= earTagModelRepository;
        }
        /// <summary>
        /// 查询显示耳标状态为已使用
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<EarTagModel>> Handle(EarTagQueryCommand request, CancellationToken cancellationToken)
        {
            return await _earTagModelRepository.GetEarTag();
        }
    }
}
